class Solution:
    def simplifyPath(self, path: str) -> str:
        path_list = path.split("/")
        while "" in path_list:
            path_list.remove("")
        while "." in path_list:
            path_list.remove(".")
        while ".." in path_list:
            index = path_list.index("..")
            path_list.pop(index)
            if index != 0:
                path_list.pop(index-1)
        return "/" + "/".join(path_list)


a = Solution()
print(a.simplifyPath("/home/"))
print(a.simplifyPath("/../"))
print(a.simplifyPath("/home//foo/"))
print(a.simplifyPath("/a/./b/../../c/"))
print(a.simplifyPath("/a/../../b/../c//.//"))
print(a.simplifyPath("/a//b////c/d//././/.."))
